Page({
    onShareAppMessage() {
        return {
            title: 'scroll-view',
            path: 'page/component/pages/scroll-view/scroll-view'
        }
    },
    data: {
        // classification: [
        //     {id: 1, name: '每日新品', handle: 'newproducts'},
        //     {id: 2, name: '热门推荐', handle: 'recommend'},
        //     {id: 3, name: '家用电器', handle: 'electricappliance'},
        //     {id: 4, name: '美妆个护', handle: 'gehu'},
        //     {id: 5, name: '3C数码', handle: 'digital'},
        //     {id: 6, name: '日用文创', handle: 'culturalcreation'},
        // ],
        classification:[],
        activeKey: 0,
        toView: 'new',
    },
    onLoad() {
        // this.setData({
        //   logs: (wx.getStorageSync('logs') || []).map((log: string) => {
        //     return {
        //       date: formatTime(new Date(log)),
        //       timeStamp: log
        //     }
        //   }),
        // })
        console.log(111111)
        var _this = this
        wx.request({
            url:'http://shequ.220514.xyz/index.php/api/consume/shop_articleindex',
            method:"POST",
            success(res){
                console.log(res)
                _this.setData({
                    classification:res.data.data
                })
            },
            fail(err){
                console.log(err)
            },

        })

    },

    scroll(e) {
        console.log(this.data.classification)
        if (e.detail.scrollTop >= 0 && e.detail.scrollTop <= 230) {
            this.setData({
                activeKey: 0
            })
        }
        if (e.detail.scrollTop >= 230 && e.detail.scrollTop <= 490) {
            this.setData({
                activeKey: 1
            })
        }
        if (e.detail.scrollTop >= 490 && e.detail.scrollTop <= 750) {
            this.setData({
                activeKey: 2
            })
        }
        if (e.detail.scrollTop >= 750 && e.detail.scrollTop <= 1020) {
            this.setData({
                activeKey: 3
            })
        }
        if (e.detail.scrollTop >= 1020 && e.detail.scrollTop <= 1280) {
            this.setData({
                activeKey: 4
            })
        }
        if (e.detail.scrollTop >= 1280) {
            this.setData({
                activeKey: 5
            })
        }

    },

    setHeight(e:any) {
        if (e.currentTarget.id == 1) {
            this.setData({
                scrollTop: 0
            })
        }
        if (e.currentTarget.id == 2) {
            this.setData({
                scrollTop: 250
            })
        }
        if (e.currentTarget.id == 3) {
            this.setData({
                scrollTop: 510
            })
        }
        if (e.currentTarget.id == 4) {
            this.setData({
                scrollTop: 770
            })
        }
        if (e.currentTarget.id == 5) {
            this.setData({
                scrollTop: 1040
            })
        }
        if (e.currentTarget.id == 6) {
            this.setData({
                scrollTop: 1300
            })
        }


    },

})
